# 项目信息
set(project_name lib_sql)
project (${project_name})

option(GENERATE_MYSQL_LIB "Generate mysql library" OFF)

# 查找当前目录下的所有源文件
FILE (GLOB SQLITE_SOURCES "sqlite/*.c" "sqlite/*.cpp" )
FILE (GLOB SQLITE_INCLUDES "sqlite/*.h" "common/*.h" )
FILE (GLOB MYSQL_SOURCES "mysql/*.cpp" )
FILE (GLOB MYSQL_INCLUDES "mysql/*.h" "common/*.h" )
# SET(ALL_FILES ${ALL_SOURCES} ${ALL_INCLUDES})

aux_source_directory(. DIR_SRCS)

if(WIN32)
    set(MYSQL_ROOT_PATH "C:/Program Files/MySQL/MySQL Server 8.0")
    set(RELEASE_LIBS ${MYSQL_ROOT_PATH}/lib/libmysql.lib)
elseif(APPLE)
    set(MYSQL_ROOT_PATH )
    set(RELEASE_LIBS ${MYSQL_ROOT_PATH}/lib/libmysql.a)
elseif(UNIX)
    set(MYSQL_ROOT_PATH )
    set(RELEASE_LIBS ${MYSQL_ROOT_PATH}/lib/libmysql.a)
endif()


IF(CMAKE_CL_64)
    set(platform x64)
ELSE(CMAKE_CL_64)
    set(platform x86)
ENDIF(CMAKE_CL_64)

add_library(lib_sqlite ${SQLITE_SOURCES})

if(GENERATE_MYSQL_LIB)
    include_directories("${MYSQL_ROOT_PATH}/include")
    add_library(lib_mysql ${MYSQL_SOURCES})
    target_link_libraries(lib_mysql ${RELAY_LIBS})
endif()